<div class="row">
    <div class="col-md-12">
        <div class="box">
            <div class="box-header with-border">
                <h3 class="box-title">
                    Dashboard List ({{$vm.list.values.length || 0}} of {{$vm.list.total}})
                </h3>
            </div>
            <div class="box-body">
                <div ng-include="'views/partials/dashboard/list/toolbar.html'"></div>

                <div class="mt-xs filter-panel" ng-include="'views/partials/dashboard/list/filters.html'" ng-show="$vm.filtering.context.showFilters"></div>

                <!-- Filters preview  -->
                <div class="row mt-xs">
                    <div class="col-md-12 clearfix">
                        <filters-preview filters="$vm.filtering.context.filters"
                            on-clear-item="$vm.removeFilter(field)"
                            on-clear-all="$vm.clearFilters()"></filters-preview>
                    </div>
                </div>

                <!-- Datalist  -->
                <div class="row mt-xs">
                    <div class="col-md-12 mv-s" ng-show="$vm.list.total === 0">
                        <div class="empty-message">No records</div>
                    </div>

                    <div class="col-md-12" ng-show="$vm.list.total > 0">
                        <psearch control="$vm.list"></psearch>

                        <table class="table table-striped case-list">
                            <thead>
                                <tr>
                                    <th width="80px">
                                        <a href class="text-default" ng-click="$vm.sortByField('status')">
                                            Status
                                            <i ng-show="$vm.filtering.context.sort.indexOf('+status') === -1 && $vm.filtering.context.sort.indexOf('-status') === -1" class="fa fa-sort"></i>
                                            <i ng-show="$vm.filtering.context.sort.indexOf('+status') !== -1" class="fa fa-caret-up"></i>
                                            <i ng-show="$vm.filtering.context.sort.indexOf('-status') !== -1" class="fa fa-caret-down"></i>
                                        </a>
                                    </th>
                                    <th>
                                        <a href class="text-default" ng-click="$vm.sortByField('title')">
                                            Title
                                            <i ng-show="$vm.filtering.context.sort.indexOf('+title') === -1 && $vm.filtering.context.sort.indexOf('-title') === -1" class="fa fa-sort"></i>
                                            <i ng-show="$vm.filtering.context.sort.indexOf('+title') !== -1" class="fa fa-caret-up"></i>
                                            <i ng-show="$vm.filtering.context.sort.indexOf('-title') !== -1" class="fa fa-caret-down"></i>
                                        </a>
                                    </th>
                                    <th style="width: 180px;">
                                        <a href class="text-default ml-xxxs" ng-click="$vm.sortByField('createdBy')" uib-tooltip="Sort by owner">
                                            Owned By
                                            <i ng-show="$vm.filtering.context.sort.indexOf('+createdBy') === -1 && $vm.filtering.context.sort.indexOf('-createdBy') === -1" class="fa fa-sort"></i>
                                            <i ng-show="$vm.filtering.context.sort.indexOf('+createdBy') !== -1" class="fa fa-caret-up"></i>
                                            <i ng-show="$vm.filtering.context.sort.indexOf('-createdBy') !== -1" class="fa fa-caret-down"></i>
                                        </a>
                                    </th>
                                    <th style="width: 150px">
                                        Dates
                                        <a href class="text-default ml-xxxs" ng-click="$vm.sortByField('createdAt')" uib-tooltip="Sort by creation date">
                                            C.
                                            <i ng-show="$vm.filtering.context.sort.indexOf('+createdAt') === -1 && $vm.filtering.context.sort.indexOf('-createdAt') === -1" class="fa fa-sort"></i>
                                            <i ng-show="$vm.filtering.context.sort.indexOf('+createdAt') !== -1" class="fa fa-caret-up"></i>
                                            <i ng-show="$vm.filtering.context.sort.indexOf('-createdAt') !== -1" class="fa fa-caret-down"></i>
                                        </a>
                                        <a href class="text-default ml-xxxs" ng-click="$vm.sortByField('updatedAt')" uib-tooltip="Sort by last update date">
                                            U.
                                            <i ng-show="$vm.filtering.context.sort.indexOf('+updatedAt') === -1 && $vm.filtering.context.sort.indexOf('-updatedAt') === -1" class="fa fa-sort"></i>
                                            <i ng-show="$vm.filtering.context.sort.indexOf('+updatedAt') !== -1" class="fa fa-caret-up"></i>
                                            <i ng-show="$vm.filtering.context.sort.indexOf('-updatedAt') !== -1" class="fa fa-caret-down"></i>
                                        </a>
                                    </th>
                                    <th style="width: 160px"></th>
                                </tr>
                            </thead>

                            <tbody>
                                <tr ng-repeat="item in $vm.list.values">

                                    <td class="wrap">
                                        <span class="label label-default clickable" ng-click="$vm.addFilterValue('status', item.status)">{{item.status}}</span>
                                    </td>

                                    <td class="wrap">
                                        <h4 class="mt-0">
                                            <a href ui-sref="app.dashboards-view({id: item._id})">{{item.title}}</a>
                                        </h4>
                                        <span class="text-muted">{{item.description}}</span>
                                    </td>
                                    <td class="nowrap">
                                        <user user-id="item.createdBy" icon-size="m"></user>
                                    </td>
                                    <td>
                                        <div ng-class="{'text-bold': $vm.filtering.context.sort.indexOf('+createdAt') !== -1 || $vm.filtering.context.sort.indexOf('-createdAt') !== -1}">
                                            C. <a href ng-click="$vm.addFilterValue('createdAt', item.createdAt)">{{item.createdAt | shortDate}}</a>
                                        </div>
                                        <div ng-if="item.updatedAt > 0" ng-class="{'text-bold': $vm.filtering.context.sort.indexOf('+updatedAt') !== -1 || $vm.filtering.context.sort.indexOf('-updatedAt') !== -1}">
                                            U. <a href ng-click="$vm.addFilterValue('updatedAt', item.updatedAt)">{{item.updatedAt | shortDate}}</a>
                                        </div>
                                    </td>
                                    <td>
                                        <div class="media-right ph-xs text-center">
                                            <a href ui-sref="app.dashboards-view({id: item._id})"><i class="fa fa-area-chart"></i> <br />View</a>
                                        </div>
                                        <div class="media-right ph-xs text-center">
                                            <a href ng-click="$vm.editDashboard(item)"><i class="fa fa-pencil"></i> <br />Edit</a>
                                        </div>
                                        <div class="media-right ph-xs text-center">
                                            <a href ng-click="$vm.duplicateDashboard(item)"><i class="fa fa-copy"></i> <br />Copy</a>
                                        </div>
                                        <div class="media-right ph-xs text-center">
                                            <a href ng-click="$vm.exportDashboard(item)"><i class="fa fa-download"></i> <br />Export</a>
                                        </div>
                                        <div class="media-right ph-xs text-center">
                                            <a href class="text-danger" ng-click="$vm.deleteDashboard(item._id)">
                                                <i class="fa fa-trash"></i> <br />Delete
                                            </a>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>

                        <psearch control="$vm.list"></psearch>
                    </div>
                </div>



            </div>
        </div>
    </div>
</div>
